package cn.ld.module.system.dal.mapper.sms;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.system.controller.admin.sms.vo.log.SmsLogPageInVO;
import cn.ld.module.system.dal.entity.sms.SmsLogEntity;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SmsLogMapper extends BaseMapperX<SmsLogEntity> {

    default PageResult<SmsLogEntity> selectPage(SmsLogPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<SmsLogEntity>()
                .eqIfPresent(SmsLogEntity::getChannelId, inVO.getChannelId())
                .eqIfPresent(SmsLogEntity::getTemplateId, inVO.getTemplateId())
                .likeIfPresent(SmsLogEntity::getMobile, inVO.getMobile())
                .eqIfPresent(SmsLogEntity::getSendStatus, inVO.getSendStatus())
                .betweenIfPresent(SmsLogEntity::getSendTime, inVO.getSendTime())
                .eqIfPresent(SmsLogEntity::getReceiveStatus, inVO.getReceiveStatus())
                .betweenIfPresent(SmsLogEntity::getReceiveTime, inVO.getReceiveTime())
                .orderByDesc(SmsLogEntity::getId));
    }

}
